TARGET := cms_task

SRC = $(wildcard *.c)
COBJS = $(patsubst %.c,%.o, $(SRC))

COMMON_SRC = $(wildcard common/*.c)
COMMON_COBJS = $(patsubst %.c,%.o, $(COMMON_SRC))
COBJS += $(COMMON_COBJS)

MODULE_SRC = $(wildcard module/*.c)
MODULE_COBJS = $(patsubst %.c,%.o, $(MODULE_SRC))
COBJS += $(MODULE_COBJS)

CFLAGS += -DXML_SHM_DIRECT_WRITE
CFLAGS += -I.
CFLAGS += -Icommon
CFLAGS += -Imodule


LDFLAGS += -lcmsmdm -lpthread


all: $(TARGET)
	cp $(TARGET) $(CMS_LIB_DIR)
	@echo "###################################"
	@echo "#        $(TARGET) "
	@echo "#        Build up successfully"
	@echo "###################################"		

$(TARGET): $(COBJS)
	$(CC) $(CFLAGS) $^ -o $@ $(LDFLAGS)

$(COBJS):%.o:%.c
	@#printf "  CC      $(*).c\n"
	$(CC) $(CFLAGS) -c $< -o $@	
	
clean:
	@echo "###################################"
	@echo "#        clean $(TARGET) "
	@echo "###################################"		
	rm -f *.o *.d $(TARGET) $(COBJS)
